package com.example.yls.demoa;

import android.graphics.Bitmap;
import android.util.LruCache;

import com.android.volley.toolbox.ImageLoader;

/**
 * Created by yls on 2019/3/18.
 */

class myLoaderCache implements ImageLoader.ImageCache {
    private LruCache<String,Bitmap> lruCache;


    public myLoaderCache(){
        int maxsize=10*1024*1024;
        lruCache=new LruCache<String,Bitmap>(maxsize){
            @Override
            protected int sizeOf(String key, Bitmap value) {
                return value.getRowBytes()*value.getHeight();
            }
        };

    }
    @Override
    public Bitmap getBitmap(String s) {



        return lruCache.get(s);
    }

    @Override
    public void putBitmap(String s, Bitmap bitmap) {

        lruCache.put(s,bitmap);


    }
}
